import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { registerMicroApps, start } from 'qiankun'

createApp(App).use(store).use(router).mount('#main')

registerMicroApps([
  {
    name: 'qiankun-admin',
    entry: '//localhost:8081',
    container: '#container',
    activeRule: '/admin'
  }
])

const childrenPath = ['/admin']

router.beforeEach((to, from, next) => {
  if (to.name) {
    next()
  }
  if (childrenPath.some((item) => to.path.includes(item))) {
    next();
  }
})

start()
